home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / diskmags / shoah_s_iss1.lha / source / LineDraw.s < prev    next >
Encoding:
Text File  |  1991-06-13  |  3.8 KB  |  133 lines

  1. ;      _______  ___                    ___        _______
  2. ;     /°-     \/. /    _____   ____   / ./       /°-     \
  3. ;     \   \___//  \___/°    \_/°   \_/   \___    \   \___/
  4. ;    _/\__    \      ~\_  /\  \  /\ ~\      °\_ _/\__    \
  5. ;    \\       /   /\   /  \/. /  \/   \ //\   / \\       /
  6. ;     \______/\__/  \_/\_____/\____/\_/_/  \_/ o \______/ Issue 1
  7.  
  8. *******************************************************************************
  9. *                                          *
  10. *            'DrawLine V1.01' By TIP/SPREADPOINT              *
  11. *            ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­              *
  12. *                                          *
  13. *******************************************************************************
  14.  
  15. DL_Width    =    40
  16. DL_Fill        =    0        ; 0=NOFILL / 1=FILL
  17.     IFEQ    DL_Fill
  18. DL_MInterns    =    $CA
  19.     ELSE
  20. DL_MInterns    =    $4A
  21.     ENDC
  22.  
  23. ;­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
  24. ;    A0 = PlanePtr, A6 = $DFF002, D0/D1 = X0/Y0, D2/D3 = X1/Y1
  25. ;    D4 = PlaneWidth > Kills: D0-D4/A0-A1 (+D5 in Fill Mode)
  26.  
  27. DrawLine:    cmp.w    d1,d3        ; Drawing only from Top to Bottom is
  28.         bge.s    .y1ly2        ; necessary for:
  29.         exg    d0,d2        ; 1) Up-down Differences (same coords)
  30.         exg    d1,d3        ; 2) Blitter Invert Bit (only at top of
  31.                     ;    line)
  32. .y1ly2:        sub.w    d1,d3        ; D3 = yd
  33.  
  34. ; Here we could do an Optimization with Special Shifts
  35. ; depending on the DL_Width value... I know it, but please, let it be.
  36.  
  37.         mulu    d4,d1        ; Use muls for neg Y-Vals
  38.         add.l    d1,a0        ; Please don't use add.w here !!!
  39.         moveq    #0,d1        ; D1 = Quant-Counter
  40.         sub.w    d0,d2        ; D2 = xd
  41.         bge.s    .xdpos
  42.         addq.w    #2,d1        ; Set Bit 1 of Quant-Counter (here it
  43.                     ; could be a moveq)
  44.         neg.w    d2
  45. .xdpos:        moveq    #$f,d4        ; D4 full cleaned (for later oktants
  46.                     ; move.b)
  47.         and.w    d0,d4
  48.     IFNE    DL_Fill
  49.         move.b    d4,d5        ; D5 = Special Fill Bit
  50.         not.b    d5
  51.     ENDC
  52.         lsr.w    #3,d0        ; Yeah, on byte (necessary for bchg)...
  53.         add.w    d0,a0        ; ...Blitter ands automagically
  54.         ror.w    #4,d4        ; D4 = Shift
  55.         or.w    #$B00+DL_MInterns,d4    ; BLTCON0-codes
  56.         swap    d4
  57.         cmp.w    d2,d3        ; Which Delta is the Biggest ?
  58.         bge.s    .dygdx
  59.         addq.w    #1,d1        ; Set Bit 0 of Quant-Counter
  60.         exg    d2,d3        ; Exchange xd with yd
  61. .dygdx:        add.w    d2,d2        ; D2 = xd*2
  62.         move.w    d2,d0        ; D0 = Save for $52(a6)
  63.         sub.w    d3,d0        ; D0 = xd*2-yd
  64.         addx.w    d1,d1        ; Bit0 = Sign-Bit
  65.         move.b    Oktants(PC,d1.w),d4    ; In Low Byte of d4
  66.                         ; (upper byte cleaned above)
  67.         swap    d2
  68.         move.w    d0,d2
  69.         sub.w    d3,d2        ; D2 = 2*(xd-yd)
  70.         moveq    #6,d1        ; D1 = ShiftVal (not necessary) 
  71.                     ; + TestVal for the Blitter
  72.         lsl.w    d1,d3        ; D3 = BLTSIZE
  73.         add.w    #$42,d3
  74.         lea    $52-2(a6),a1    ; A1 = CUSTOM+$52
  75.  
  76. ; WARNING : If you use FastMem and an extreme DMA-Access (e.g. 6
  77. ; Planes and Copper), you should Insert a tst.b (a6) here (for the
  78. ; shitty AGNUS-BUG)
  79.  
  80. .wb:        btst    d1,(a6)        ; Waiting for the Blitter...
  81.         bne.s    .wb
  82.     IFNE    DL_Fill
  83.         bchg    d5,(a0)        ; Inverting the First Bit of Line
  84.     ENDC
  85. ;-------------- Not necessary, only for testing purposes ! (Cf Init Part...)
  86. ;        move.w    #$8000,$74-2(a6)
  87. ;        move.w    #-1,$44-2(a6)
  88. ;        move.w    #-1,$72-2(a6)
  89. ;        move.w    #DL_Width,$60-2(a6)
  90. ;        move.w    #DL_Width,$66-2(a6)
  91. ;--------------
  92.         move.l    d4,$40-2(a6)    ; Writing to the Blitter Regs as fast
  93.         move.l    d2,$62-2(a6)    ; as possible
  94.         move.l    a0,$48-2(a6)
  95.         move.w    d0,(a1)+
  96.         move.l    a0,(a1)+    ; Shit-Word Buffer Ptr...
  97.         move.w    d3,(a1)
  98.         rts
  99. ;­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
  100.     IFNE    DL_Fill
  101. SML        =     2
  102.     ELSE
  103. SML        =    0
  104.     ENDC
  105.  
  106. Oktants:    dc.b    SML+1,SML+1+$40
  107.         dc.b    SML+17,SML+17+$40
  108.         dc.b    SML+9,SML+9+$40
  109.         dc.b    SML+21,SML+21+$40
  110. ;­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
  111. ;        Optimized Init Part... A6 = $DFF000 > Kills : D0-D2
  112.  
  113. DL_Init:    addq.w    #2,a6        ; A6 = $DFF002 for DrawLine !
  114.         moveq    #-1,d1
  115.     IFGT    DL_Width-127
  116.         move.w    #DL_Width,d0
  117.     ELSE
  118.         moveq    #DL_Width,d0
  119.     ENDC
  120.         moveq    #6,d2
  121. .wb:        btst    d2,(a6)
  122.         bne.s    .wb
  123.         move.w    d1,$44-2(a6)
  124.         move.w    d1,$72-2(a6)
  125.         move.w    #$8000,$74-2(a6)
  126.         move.w    d0,$60-2(a6)
  127.         move.w    d0,$66-2(a6)
  128.         rts
  129.  
  130. DL_Exit:    subq.w    #2,a6        ; A6 = $DFF000
  131.         rts
  132.  
  133.